import { type baseListInfo } from '@/page/types/base/baseList'
import { type selectDeptInfo } from '@/page/types/admin/dept'
import { type pageInfo } from '@/page/types/base/baseRequestPage'

export interface JobInfo {
  /**
   * Id 生成策略为UUID
   */
  id: string

  /**
   * 是否删除 一般默认不删除 false
   */
  status: number

  /**
   * 创建时间 填充策略为插入自动填充
   */
  createTime: string
  /**
   * 名称
   */
  name: string
  /**
   * 岗位编码
   */
  code: string
  /**
   * 排序
   */
  sort: number

  /**
   * 描述
   */
  describes: string
  /**
   * 部门名称
   */
  deptName: string
  /**
   *  公司id
   */
  companyId: string | null
  /**
   * 岗位id
   */
  deptId: string | null
}

export interface jobSInfo extends pageInfo {
  /**
   * 名称
   */
  name: string

  deptName: string
}

export class JobClass {
  jobS: jobSInfo = {
    /**
     * 名称
     */
    name: '',
    deptName: '',
    page: 1,
    size: 10,
    total: 0
  }

  tableData = [] as JobInfo[]
  page = 0
  size = 10
  total = 0
  jobDialog = false
  jobAdd: JobInfo = {
    id: '',
    status: 0,
    createTime: '',
    name: '',
    code: '',
    sort: 0,
    describes: '',
    deptName: '',
    companyId: null,
    deptId: null
  }

  rules = {
    companyId: [
      {
        required: true,
        message: '公司不能为空',
        trigger: 'blur'
      }
    ],
    deptId: [
      {
        required: true,
        message: '部门不能为空',
        trigger: 'blur'
      }
    ],
    name: [
      {
        required: true,
        message: '岗位名称不能为空',
        trigger: 'blur'
      }
    ],
    code: [
      {
        required: true,
        message: '岗位编码不能为空',
        trigger: 'blur'
      }
    ],
    sort: [
      {
        required: true,
        message: '岗位排序不能为空',
        trigger: 'blur'
      }
    ]
  }

  selectCompanyData = [] as baseListInfo[]
  selectDeptTree = [] as selectDeptInfo[]
  props = {
    label: 'deptName',
    value: 'id',
    children: 'children',
    emitPath: false
  }
}
